package com.ueboot.weishop.admin.batch.jobs;


import com.ueboot.weishop.admin.batch.tasklet.InitSettlementBatchTasklet;
import org.springframework.batch.core.Job;
import org.springframework.batch.core.Step;
import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing;
import org.springframework.batch.core.configuration.annotation.JobBuilderFactory;
import org.springframework.batch.core.configuration.annotation.JobScope;
import org.springframework.batch.core.configuration.annotation.StepBuilderFactory;
import org.springframework.batch.core.launch.support.RunIdIncrementer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.Map;

@Configuration
@EnableBatchProcessing
public class JobInitSettleBatchConfiguration {

    @Autowired
    private JobBuilderFactory jobBuilderFactory;

    @Autowired
    private StepBuilderFactory stepBuilderFactory;

    //job
    @Bean
    public Job jobSettleBatch() {
        return jobBuilderFactory.get("jobSettleBatch")
                .incrementer(new RunIdIncrementer())
                .start(step1())
                .build();
    }

    //step：清理历史数据以及文件
    @Bean
    @JobScope
    public Step step1() {
        return stepBuilderFactory.get("step1")
                .<Map<String, String>, String>chunk(100)
                .build();
    }


}
